import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'

//导入组件
import LoginVue from '@/views/Login.vue'
import LayoutVue from '@/views/Layout.vue';
//导入 二级路由
import ArticleCategoryVue from '@/views/article/ArticleCategory.vue'
import ArticleManageVue from '@/views/article/ArticleManage.vue'
import UserAvatarVue from '@/views/user/UserAvatar.vue'
import UserInfoVue from '@/views/user/UserInfo.vue'
import UserResetPasswordVue from '@/views/user/UserResetPassword.vue'

import SearchVue from '@/views/article/search.vue'

import UserInfoVue2 from '@/views/user/UserInfo2.vue'

//定义路由关系
const routes = [
    { path: '/login', component: LoginVue },
    //
    {   
        path: '/', component: LayoutVue,
        //redirect默认重定向的路径
        redirect:'/article/manage',
        children:[
        //配置子路由
        {path:'/article/category',component:ArticleCategoryVue},
        {path:'/article/manage',component:ArticleManageVue},
        {path:'/user/avatar',component:UserAvatarVue},
        {path:'/user/info',component:UserInfoVue},
        {path:'/user/resetpassword',component:UserResetPasswordVue},
        {path:'/user/info2',component:UserInfoVue2},
        {path:'/article/search',component:SearchVue}
    ] 
}
]

//创建路由器
const router = createRouter({
    history: createWebHistory(),//路由模式设置
    routes: routes//传入路由关系
})

//导出路由
export default router